package com.blog.redis.sub;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lambdaworks.redis.RedisClient;
import com.lambdaworks.redis.api.StatefulRedisConnection;
import com.lambdaworks.redis.api.sync.RedisCommands;

//@Component("postCommentListner")
public class PostCommentListner implements Runnable {
    @Autowired
    private RedisClient redisClient;
    private ThreadLocal<String> tl = new ThreadLocal<String>();

    public PostCommentListner(String channelName) {
        tl.set(channelName);
    }

    @Override
    public void run() {
        StatefulRedisConnection<String, String> connection = redisClient.connect();
        RedisCommands<String, String> syncCommands = connection.sync();

        syncCommands.set("key", "Hello, Redis!");

        connection.close();
    }
}
